var t = getApp();

Page({
    data: {
        show: !1,
        detail: {
            value: "",
            type_name: "",
            ad_link: "",
            id: ""
        },
        list: [],
        current_page: 1,
        last_page: 0
    },
    showOverlay: function(t) {
        var a = t.currentTarget.dataset.id;
        this.setData({
            show: !0
        }), this.getDetail(a);
    },
    getDetail: function(a) {
        var e = this, i = t.getNetAddresss("plugin.love-speed-pool.frontend.redpack.detail");
        t._getNetWork({
            url: i,
            data: {
                lr_id: a
            },
            success: function(a) {
                if (1 == a.data.result) {
                    var i = a.data.data.detail;
                    e.setData({
                        "detail.value": i.value,
                        "detail.type_name": i.type_name,
                        "detail.ad_link": i.ad_link,
                        "detail.id": i.id
                    });
                } else t.tips(a.data.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    confirm: function() {
        var a = this;
        t._getNetWork({
            url: t.getNetAddresss("plugin.love-speed-pool.frontend.redpack.receive"),
            data: {
                lr_id: this.data.detail.id
            },
            success: function(e) {
                1 == e.data.result ? (a.getData(), t.tips(e.data.msg)) : t.tips(e.data.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    onClickHide: function() {
        this.setData({
            show: !1
        });
    },
    onLoad: function(t) {
        this.getData();
    },
    getData: function() {
        var a = this;
        t._getNetWork({
            url: t.getNetAddresss("plugin.love-speed-pool.frontend.redpack.index"),
            success: function(e) {
                var i = e.data.data.list;
                1 == e.data.result ? (a.setData({
                    list: i.data,
                    current_page: i.current_page,
                    last_page: i.last_page
                }), wx.setNavigationBarTitle({
                    title: e.data.data.diy_names.diy_receive_red_action
                })) : t.tips(e.data.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        var a = this;
        if (this.data.current_page >= this.data.last_page) return !1;
        var e = this.data.current_page + 1;
        t._getNetWork({
            url: t.getNetAddresss("plugin.love-speed-pool.frontend.redpack.index"),
            data: {
                page: e
            },
            success: function(e) {
                if (1 == e.data.result) {
                    var i = a.data.list.concat(e.data.data.list.data);
                    a.setData({
                        list: i,
                        current_page: e.data.data.list.current_page,
                        last_page: e.data.data.list.last_page
                    });
                } else t.tips(e.data.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    onShareAppMessage: function() {}
});